package com.viroyal.monitorlib.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

/**
 * Created by cxy_nj on 2016/12/28.
 */

public class SystemUtils {
    /**
     * 获取本地版本号
     *
     * @param context
     * @return
     */
    public static int getAppVersionCode(String packageName, Context context) {
        try {
            PackageManager manager = context.getPackageManager();
            PackageInfo info = manager.getPackageInfo(packageName, 0);
            int vCode = info.versionCode;
            return vCode;
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }
    }
}
